/**
 * [employeeFilterParam description]
 * @type {Object}
 */
var employeeFilterParam = {
    inited: false,
    cache: {},
    singleShop: false,//是否是单门店
    params:{
        onjobStatus: '',//在职状态
        shopId: '',//门店Id
        shopName: '',
        roleId: ''//角色
    }
};
(function(doc, win) {

// sui 页面就绪时间
    $(doc).on("pageInit", "#employeeFilterPage", function(e, pageId, $page, isBack) {
        var user = sessionStorageClient.getJSON("user");
        if (isBack) {
            //选择的门店信息
            employeeFilterParam.params.shopId = employeeStoreListFilterParam.shopId;
            employeeFilterParam.params.shopName = employeeStoreListFilterParam.shopName;
            if(employeeFilterParam.params.shopId != '') {
                $('#employeeFilterPage .page-body .store-name').html(employeeFilterParam.params.shopName);
            } else {
                $('#employeeFilterPage .page-body .store-name').html("全部门店");
            }
        } else {
            CommonUtil.render($("#employeeShopDiv" ), "employeeTpl", { role: user.role });
            var prePageParam = CommonUtil.takeOutParamObject();
            employeeFilterParam.selectedOption = prePageParam.selectedOption;
            //获取门店数据
            var controller = new EmployeeFilterController();
            controller.getShopList({}, prePageParam,true);
        
        }
         if(employeeFilterParam.singleShop||user.role==4) {    
            $('#employeeFilterPage  #filterEmployeeStore').addClass("hide");                         
        }
    });


    // 选择
    $(doc).on('click','#employeeFilterPage .filter-item',function(){
        $(this).addClass("selected").siblings().removeClass("selected");
        var onjobStatus = $(this).attr("onjobStatus");
        if (onjobStatus) {
            employeeFilterParam.params.onjobStatus = parseInt(onjobStatus);
        } else {
            var roleId = $(this).attr("roleId");
            employeeFilterParam.params.roleId = parseInt(roleId);
        }
    });
   
    // 重置
    $(doc).on('click','#employeeFilterPage .header .right a',function(){
        $('#employeeFilterPage .filter-item').removeClass("selected");
        $('#employeeFilterPage  .page-body .store-name').html("全部门店");
        employeeFilterParam.params.roleId = '';
        employeeFilterParam.params.onjobStatus = '';
        employeeFilterParam.params.shopId = sessionStorageClient.getJSON("user").role==4?sessionStorageClient.getJSON("user").selfShopId:'';
        employeeFilterParam.params.shopName = '';
    });

    // 选择门店
    $(doc).on('click','#employeeFilterPage .page-body .filter-list-content .filter-item-store',function(){
        $.router.load("employee_store_list.html");
    });

    // 点击返回，清空选项
    $(doc).on('click','#employeeFilterPage .scroll-view .header .left',function(){
        $('#employeeFilterPage .page-body').empty();
    });
    $(doc).on('click','#employeeFilterPage .filter-item',function(){
        $(this).addClass("selected").siblings().removeClass("selected");
    })
})(document, window);

